package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhmoveInwhDAO;
import com.cssy.yd.logic.entity.LogicWhmoveInwhDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-23
 */
public class LogicWhmoveInwhDAOImpl extends SqlMapClientDaoSupport implements LogicWhmoveInwhDAO {

    /**
     * 插入数据
     * @param logicWhmoveInwhDO
     * @return 插入数据的主键
     */
    public String insertLogicWhmoveInwhDO(LogicWhmoveInwhDO logicWhmoveInwhDO) throws DataAccessException {
    	logicWhmoveInwhDO.setVersion(Double.parseDouble("1"));
    	Object id = getSqlMapClientTemplate().insert("LogicWhmoveInwh.insert", logicWhmoveInwhDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhmoveInwhDO
     * @return 查出的记录数
     */
    public Integer countLogicWhmoveInwhDOByExample(LogicWhmoveInwhDO logicWhmoveInwhDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwh.countByDOExample", logicWhmoveInwhDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhmoveInwhDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhmoveInwhDO(LogicWhmoveInwhDO logicWhmoveInwhDO) throws DataAccessException {
    	logicWhmoveInwhDO.setVersionbt(logicWhmoveInwhDO.getVersion());
    	logicWhmoveInwhDO.setVersion(logicWhmoveInwhDO.getVersion()+1);
    	int result = getSqlMapClientTemplate().update("LogicWhmoveInwh.update", logicWhmoveInwhDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhmoveInwhDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhmoveInwhDO> findListByExample(LogicWhmoveInwhDO logicWhmoveInwhDO) throws DataAccessException {
        List<LogicWhmoveInwhDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveInwh.findListByDO", logicWhmoveInwhDO);
        return list;
    }

    /**
     * 根据主键获取logicWhmoveInwhDO
     * @param id
     * @return logicWhmoveInwhDO
     */
    public LogicWhmoveInwhDO findLogicWhmoveInwhDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhmoveInwhDO logicWhmoveInwhDO = (LogicWhmoveInwhDO) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwh.findByPrimaryKey", id);
        return logicWhmoveInwhDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhmoveInwhDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhmoveInwh.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicWhmoveInwhDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicWhmoveInwhDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveInwh_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwh_ex.count", scs);
  	      return count;
  	}

	@Override
	public LogicWhmoveInwhDO findLastInwhDO(SearchConditions scs)
			throws DataAccessException {
		LogicWhmoveInwhDO logicWhmoveInwhDO = (LogicWhmoveInwhDO) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwh_ex.findLastInwhDO", scs);
		return logicWhmoveInwhDO;
	}
	
}